/*
 * UserInfo.cpp
 *
 *  Created on: May 16, 2012
 *      Author: Lucho0
 */

#include "UserInfo.h"

#define CIEN 100
#define USERINFO_FONT_SIZE 8

UserInfo::UserInfo(std::string userName, int life, int posX, int posY,
		Widget* parent) :
	Widget(posX, posY, NULL, parent) {

	Color colorBlanco = Color(255, 255, 255);
	this->userName = new Label(userName, 14, parent, posX, posY, 200, 200, 50);

	Parcel* lblParcel = this->userName->getBoundaries();

	//Calculo la posicion relativa del progress bar
	//abajo del nombre
	int posYBar = posY + lblParcel->height;
	this->progressBar = new ProgressBar(CIEN, posX, posYBar, this);

	this->initialLife = life;

	delete lblParcel;
}

UserInfo::~UserInfo() {
	delete progressBar;
	delete userName;
}

void UserInfo::updatePosition() {
	Parcel* lblParcel = this->userName->getBoundaries();

	//lblParcel->width = this->userName->parcel->width;

	this->userName->parcel->posX = this->parent->parcel->posX
			+ (lblParcel->width / 2) - (this->parent->parcel->width / 2) + 7;
	this->userName->parcel->posY = this->parent->parcel->posY
			+ this->parent->parcel->height+7;

	//Calculo la posicion relativa del progress bar
	//abajo del nombre
	int posYBar = this->userName->parcel->posY + lblParcel->height / 2;

	this->progressBar->parcel->posX = this->parent->parcel->posX
			- (this->progressBar->parcel->width / 2) + 7;
	;
	this->progressBar->parcel->posY = posYBar;
}

void UserInfo::reduceLife(int value) {
	//this->progressBar->setPorcent(value);
}

void UserInfo::showOn(SDL_Surface* surface) {
	userName->showOn(surface);
	progressBar->showOn(surface);
}

